﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Commerce/Views/Shared/Backend.Master"
    Inherits="System.Web.Mvc.ViewPage<IAdministrator>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <h3 class="title">
        <%: "Administrators".Localize()%></h3>
    <ul class="tabs clearfix">
        <li class="current"><a href="/commerce/accounts">
            <%:"Administrators".Localize() %></a></li>
        <li><a href="/commerce/accounts/changepassword">
            <%:"Change Password".Localize() %></a></li>
    </ul>
    <div class="tab-content">
        <div class="command">
            <%  using (Html.BeginForm("AddAdministrator", "Account"))
                { %>
            <%: Html.LabelFor(m => m.UserName) %>
            <%: Html.TextBoxFor(m => m.UserName) %>
            <button type="submit">
                <%: "Add Administrator".Localize() %></button>
            <%: Html.ValidationMessageFor(m => m.UserName)%>
            <%} %>
        </div>
        <div class="table-container">
            <%  using (Html.BeginForm("DeleteAdministrator", "Account"))
                { %>
            <input type="hidden" name="userName" id="userName" value="" />
            <table>
                <thead>
                    <tr>
                        <th>
                            <%:"User Name".Localize()%>
                        </th>
                        <th class="action">
                            <%:"Delete".Localize()%>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <% 
                    var index = 0;
                    var list = ViewData["Administrators"] as IEnumerable<IAdministrator>;
                    foreach (var item in list)
                    {
                    %>
                    <tr <%= index++ % 2 == 0? "": "class='even'" %>>
                        <td>
                            <%: item.UserName%>
                        </td>
                        <td>
                            <input type="submit" class="delete button" value="<%: "Delete".Localize() %>" data="<%: item.UserName %>" />
                        </td>
                    </tr>
                    <%
}
                    %>
                </tbody>
            </table>
            <%} %>
        </div>
    </div>
</asp:Content>
<asp:Content ID="JsContent" ContentPlaceHolderID="ScriptContent" runat="server">
    <script type="text/javascript">
      var confirm_message = "<%:"Are you sure to delete this administrator?".Localize() %>";
    </script>
    <%
        using (var clientLoader = ClientLoader.RegisterInstance())
        {
            clientLoader.Require("account.index.js");
        }
    %>
</asp:Content>
